package com.mti.epivisitemobile.view
{
	import com.mti.epivisitemobile.model.HtmlProxy;
	
	import mx.events.FlexEvent;
	
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	public class HtmlViewMediator extends Mediator
	{
		public static const NAME:String = "HtmlViewMediator";
		
		public function HtmlViewMediator(viewComponent:HtmlView)
		{
			super(NAME, viewComponent);
			
			viewComponent.addEventListener(FlexEvent.CREATION_COMPLETE, handleViewCreated);
		}
		
		private function handleViewCreated(evt:FlexEvent):void
		{
			view.removeEventListener(FlexEvent.CREATION_COMPLETE, handleViewCreated);
			
			var proxy:HtmlProxy = HtmlProxy(facade.retrieveProxy(HtmlProxy.NAME));
			view.webView.loadString(proxy.loadHtml());
		}
		
		private function get view():HtmlView
		{
			return HtmlView(viewComponent);
		}
	}
}